package headListDesignPatterns.duckDemo;

import headListDesignPatterns.duckDemo.behavior.FlyBehavior;
import headListDesignPatterns.duckDemo.behavior.QuackBehavior;

//注意不要用abstract、因为（比如叫--quack）不是所有的都会、
// 设置为抽象类子类就必须去实现它------好像还是可以用抽象类
public abstract class Duck {
    private FlyBehavior flyBehavior=null;
    private QuackBehavior quackBehavior=null;
/*    FlyBehavior flyBehavior;
    QuackBehavior quackBehavior;*/

    public FlyBehavior getFlyBehavior() {
        return flyBehavior;
    }

    public void setFlyBehavior(FlyBehavior flyBehavior) {
        this.flyBehavior = flyBehavior;
    }

    public QuackBehavior getQuackBehavior() {
        return quackBehavior;
    }

    public void setQuackBehavior(QuackBehavior quackBehavior) {
        this.quackBehavior = quackBehavior;
    }

    public void performQuack() {
        quackBehavior.quack();
    }

    public void performFly() {
        flyBehavior.fly();
    }

    public void swim() {
        System.out.println("all ducks float,even decoys");
    }

    public abstract void display();

    public Duck() {
    }
}
